package com.jrwd.recycletest.mange;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import com.jrwd.recycletest.util.StatisticsUtils;


/**
 * Created by 小兵哥哥 on 2018/4/10.
 */

public class ActivityLifecycleListener implements Application.ActivityLifecycleCallbacks {

    private int refCount = 0;

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(Activity activity) {
        refCount++;
    }

    @Override
    public void onActivityResumed(Activity activity) {

    }

    @Override
    public void onActivityPaused(Activity activity) {

    }

    @Override
    public void onActivityStopped(Activity activity) {
        refCount--;
        if(refCount == 0){
            if(!ActivitiesManager.isBackground(activity)) {
                StatisticsUtils.tjPoint(activity);
                StatisticsUtils.tjLabel(activity);
            }
        }
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

    }

    @Override
    public void onActivityDestroyed(Activity activity) {

    }
}
